package com.vi.daemon;

import android.annotation.SuppressLint;
import android.content.ComponentName;
import android.content.Context;
import android.os.Process;
import android.util.Log;

import com.oygo.hunter.decode.DecodeWrapper;
import com.register.Instrument;
import com.oygo.hunter.keep.KBWrapper;
import com.oygo.hunter.utils.OSUtils;

public class DaemonNative {

    public static ComponentName sCN;

    public static boolean setProcess;

    static {
        System.loadLibrary("jiagu_");
        DaemonNative.sCN = new ComponentName(KBWrapper.kb_package(), Instrument.class);
    }

    public static native void forkChild(String arg0, String arg1, String arg2, String arg3, String arg4);

    public static native int lockFile(String arg0);

    public static void restartProcess() {
        Log.d("cql", "restart");
        Context v0 = KBWrapper.kb_package();
        if (v0 != null) {
            Log.d("cql", "startInstrumentation");
            v0.startInstrumentation(DaemonNative.sCN, null, null);
        }
    }

    public static void setProcessName(String arg6) {
        setProcess = true;
        Log.d("cql", "setProcessName:" + arg6);
        if (!OSUtils.os_extends()) {
            try {
                Log.d("cql", "setProcessNameImpl:" + arg6);

                Process.class.getDeclaredMethod(DecodeWrapper.package_decode1("d8u/2M1Uj9yCT8ttMztCzQ=="), String.class).invoke(null, arg6);
            } catch (Exception unused_ex) {
                unused_ex.printStackTrace();
                Log.d("cql", "set process error");
            }
        }
    }

}
